<%--
  Created by IntelliJ IDEA.
  User: lb
  Date: 15-12-22
  Time: 下午2:43
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<div class="weekTime">
    <c:forEach items="${houseWeekDTO.houseWeekTimeDTOs}" var="houseWeekTimeDTO" varStatus="status">
        <div class="week">
            开始：<input type="text" class="times" id="addStart${status.index}"
                      onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'addEnd${status.index}\');}'})" value="${houseWeekTimeDTO.start}">&nbsp;
            结束：<input type="text" class="times" id="addEnd${status.index}"
                      onFocus="WdatePicker({minDate:'#F{$dp.$D(\'addStart${status.index}\');}'})" value="${houseWeekTimeDTO.end}">
            <a class="deletediv">删除</a>
        </div>
    </c:forEach>
    <a>添加时间片断</a>

</div>
<script>
    $(".weekTime>a").on('click', function () {
        var randomtime =new Date().getTime();
        var  s = " <div class=\"week\">\n" +
                " 开始：<input type=\"text\" class=\"times\" id=\"addStart"+randomtime+"\"\n" +
                " onFocus=\"WdatePicker({maxDate:'#F{$dp.$D(\\'addEnd"+randomtime+"\\');}'})\" value=\"\">&nbsp;\n" +
                " 结束：<input type=\"text\" class=\"times\" id=\"addEnd"+randomtime+"\"\n" +
                " onFocus=\"WdatePicker({minDate:'#F{$dp.$D(\\'addStart"+randomtime+"\\');}'})\" value=\"\">\n" +
                "<a class=\"deletediv\">删除</a>"+
                " </div>";
        $(this).parents("div.weekTime").append(s)
    })

    $(".weekTime").on('click','.week .deletediv',function(){
         $(this).parents(".week").remove();
    })

</script>
